<template>
  <div class="search">
    <div class="header">
      <div class="header-input">
        <span class="iconfont">&#xe600;</span>
        <input type="search" class="mui-input-clear" placeholder="输入向导/城市/景点" />
      </div>
      <div class="header-right" @click="$router.go(-1)">取消</div>
    </div>

    <div class="hot-guide">
      <my-title3 titleName="热搜向导" moreLink="/search"></my-title3>
    </div>

    <div class="hot-senic">
      <my-title3 titleName="热搜景点" moreLink="/search"></my-title3>
    </div>

    <div class="hot-city">
      <my-title3 titleName="热搜城市" moreLink="/search"></my-title3>

      <div class="hot-city-content">
        <my-ul>
          <my-li class="hot-city-li" v-for="(city, index) in cityList" :key="index" @click.native="$router.push('/cityGuide/' + city.id)">
            <div class="hot-city-img-wrapper">
              <img class="hot-city-img" :src="'static/img/server/city/icon/'+ city.spell + '.jpg'" />
            </div>
            <div class="hot-city-img-title">{{city.name}}</div>
          </my-li>
        </my-ul>
      </div>
    </div>
  </div>
</template>

<script>
import { fetchPostData, fetchGetData } from "@/api/fetch.js";
export default {
  name: "search",
  data() {
    return {
      value: "",
      result: [{ id: "1", title: "zhangsan", value: "zhangshang1" }],
      cityList: []
    };
  },
  mounted() {
    fetchPostData("/api/area/cityList", {
      pageNum: "2",
      pageSize: "6"
    }).then(res => {
      if (res.status == 1) {
        console.log(res.data);
        this.cityList = res.data.rows;
      } else {
        console.log("fail");
      }
    });
  }
};
</script>

<style lang="stylus" scoped>
@import '~@/assets/style/variable.styl';

.search {
  background-color: #efefef;
  height: 100%;
  padding-top: 60px;
  box-sizing: border-box;

  .header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 999;
    display: flex;
    line-height: 1.2rem;

    // background-color: #efefef;
    .header-input {
      flex: 1;
      border-radius: 15px;
      margin-top: 15px;
      margin-left: 0.2rem;
      padding-left: 0.2rem;
      height: 30px;
      line-height: 30px;
      background-color: #fff;
      border: solid 1px $themeColor;
      color: #ccc;

      input {
        height: 30px;
        vertical-align: top;
        width: 90%;
      }
    }

    .header-right {
      width: 1rem;
      float: right;
      text-align: center;
      // color: #fff;
    }
  }

  >>> .title {
      padding: 0 0.3rem;
    }


  .hot-city {
    
    .hot-city-li {
      height: 0;
      padding-bottom: 28%;

      .hot-city-img-wrapper {
        border-radius: 0.18rem;
        overflow: hidden;
        width: 100%;
        padding-bottom: 100%;
        height: 0;
        background-color: #ccc;
        margin: 0 auto;

        .hot-city-img {
          width: 100%;
        }
      }

      .hot-city-img-title {
        position: absolute;
        max-width: 100%;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        z-index: 1;
        color: #eee;
        font-size: 0.45rem;
      }
    }
  }
}
</style>